function set_charset($charset)
{
// check mysql version first.
$serverVersion = mysql_get_server_info($this->dbh); 
$version = explode('.', $serverVersion); 
if ($version[0] < 4) return; 

// check if utf8 support was compiled in 
$result = mysql_query("SHOW CHARACTER SET like 'utf8'", 
$this->dbh); 
if (mysql_num_rows($result) < = 0) return;

if ($charset == 'utf-8' || $charset == 'UTF-8')
$charset = 'utf8';
@mysql_query("SET NAMES '$charset'", $this->dbh); 
}